﻿define([
   "dojo/_base/declare",
   "ow-epi-listProperty/widgets/ListPropertyWidget",
   "ow-epi-listProperty/widgets/specialized/ImageListItemPropertyWidget",

    "xstyle/css!./ImageListPropertyWidget.css"
],
function (
    declare,
    _ListPropertyWidget,
    ImageListItemPropertyWidget
) {

    return declare("ow-epi-listProperty.widgets.specialized.ImageListPropertyWidget", [_ListPropertyWidget], {

        acceptDataTypes: ["fileurl"],

        postMixInProperties: function () {
            this.inherited(arguments);
        },

        postCreate: function () {
            this.inherited(arguments);

            this.listItemConstructorFunction = ImageListItemPropertyWidget;
            dojo.addClass(this.nodeItemsCollection, 'image-list');
            dojo.addClass(this.domNode, 'image-list');
        },

        onWidgetDropData: function (dndData) {
            if (this.readOnly) {
                return;
            }
            if (dndData.length === 1) {
                var newItem = {};
                newItem[this.itemWidgetSettings.imageUrlPropertyName] = dndData[0].data;
                this.addNewItem(newItem);
            }
        }
    });
});